#include <bits/stdc++.h>

#define in read()
#define ep emplace
#define eb emplace_back
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using pii = pair < int , int >;
using vec = vector < int >;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 2e5 + 10;

int vis[N], tim;
int visc[N], n, K, c[N], RT, siz[N], son[N], ans = 1e9, fa[N];
vec G[N], pot[N];
bool pvis[N];

void dfs(int x, int p) {
	siz[x] = 1; son[x] = 0; 
	for(auto y : G[x]) if(!pvis[y] && y ^ p) dfs(y, x), siz[x] += siz[y], son[x] = max(son[x], siz[y]);
}

void tdfs(int x, int p, int tsz) {
	vis[x] = tim; for(auto y : G[x]) if(!pvis[y] && y ^ p) tdfs(y, x, tsz); 
	son[x] = max(son[x], tsz - siz[x]); if(!RT || son[x] < son[RT]) RT = x; 
}

void calc(int x, int p) { fa[x] = p; for(auto y : G[x]) if(!pvis[y] && y ^ p) calc(y, x); }

queue < int > q;

void divide(int x) {
	RT = 0, ++tim; dfs(x, 0); tdfs(x, 0, siz[x]); x = RT; pvis[x] = true;
	calc(x, 0); while(q.size()) q.pop();
	q.ep(c[x]); visc[c[x]] = tim;
	bool fl = 0; int tot = 0;
	while(q.size() && !fl) {
		int t = q.front(); q.pop(); tot++;
		for(auto u : pot[t]) {
			if(vis[u] != tim) { fl = true; break; }
			for(int v = fa[u]; v; v = fa[v]) if(visc[c[v]] != tim) visc[c[v]] = tim, q.ep(c[v]); else break;
		}
	} if(!fl) ans = min(ans, tot);
	for(auto y : G[x]) if(!pvis[y]) divide(y);
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
	n = in, K = in; rep(i, 2, n) { int u = in, v = in; G[u].eb(v); G[v].eb(u); }
	rep(i, 1, n) pot[c[i] = in].eb(i);
	divide(1); printf("%d\n", ans - 1); return 0;
}
